Page({
  data: {
    box_id:'',
    bonus:{
      title:'一等奖',
      name:'华为手机',
      type:0,
      activity_url:''
    }
  },
  onLoad(e) {
    let box_id=e.box_id;
    my.getSystemInfo({
      success: (res) => {
        console.log(res)
        this.setData({
          windowHeight: res.windowHeight
        })
      },
    });
    this.setData({
      box_id:e.box_id
    })
    this.loadData(box_id)
  },
  async chooseAddress(){
    my.navigateTo({
      url: `../address/address?box_id=${this.data.box_id}`
    });
  } ,
  getCoupon(){
    my.setClipboard({
      text: this.data.bonus.activity_url
    });
    my.alert({
      content:'复制成功，请粘贴到浏览器领取'
    })
  } ,
  async loadData(box_id){
    const {cloud}=getApp();
    const res= await cloud.application.httpRequest({
      path:'/index.php/index/tb/getbox2',
      method:'GET',
      params:{
        shop_id:getApp().globalData.shop_id,
        box_id:box_id
      }

    })
    this.setData({
      bonus:res
    })

  }
  
});
